<style>
.jyui_cell_col .red {color: red;}
.fui-icon-group.col-7 .fui-icon-col {width: 14.28%;}
.signed {position: absolute;top:0;right:0.2rem;color:red;}
.fui-number .minus:before, .fui-number .plus:before {
	border-left: 0 solid #d9d9d9;
}
.fui-number .minus:after, .fui-number .plus:after {
	border-right: 0 solid #d9d9d9;
}
.fui-number:before {
	border-top: 0 solid #d9d9d9;
}
.fui-number:after {border-top: 0 solid #d9d9d9;}
.fui-number .num {
	color:#666;
}
.fui-number .num {
	color:#666;
}
.fui-number.small {
	height: 1.2rem;
	width: auto;
	line-height: 1.2rem;
}
.fui-number .minus, .fui-number .plus {
	z-index:0;
}
.fui-number.small .minus{
	color: {{main.syscolor || '#63BE72'}};
	padding-top:1px;
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
 .fui-number.small .plus {
	color: #fff;
	padding-top:1px;
	background: {{main.syscolor || '#63BE72'}};
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
</style>
<div class='fui-page fui-page-current' ng-if="pagedata.op=='main'">
    <div class='fui-content'>
		<div style="padding:0.5rem">
       <div class="tips tips-yellow" style="margin:0">
               <i class="fa fa-bullhorn"></i> 设置本订单的预约定期配送方式，如果不会设置，可以让配送员或者店员帮忙设置！
         </div>
		<div class="fui-cellone" style="text-align:left">
				<div class="fui-cellone-info bold">预约配送日期选择！</div>
				<div class="fui-cellone-remark noremark">
				<span class="btn btn-sm btn-success" style="background:#18bc9c;line-height:2" ng-click="pagedata.peiset.days='';">清空全部</span>
				</div>
		</div>
		<div class="fui-cellone bold" style="padding:0;padding-bottom:0.3rem">
				<div ng-click="pagedata.upmonth(0);" class="fui-cellone-info" style="color:#18bc9c">
					<i class="icon icon-back" style="font-size:0.8rem"/>上月
				</div>
				<div class="fui-cellone-info c">
					{{pagedata.currentyear}}-{{pagedata.currentmonth}}
				</div>
				<div ng-click="pagedata.upmonth(1);" class="fui-cellone-info r" style="color:#18bc9c">
					下月<i class="icon icon-more" style="font-size:0.8rem"/>
				</div>
		</div>
		<div class="radius" style="background:#fff;padding-top:0.3rem">
				<div class="fui-icon-group noborder col-7">
					<div class="fui-icon-col" ng-repeat="week in pagedata.params.work_weekarray" style="margin-top:0">
						<label class="jyui_cell_col" style="color:#ddd">
							<div class="timetitle"><span>{{week}}</span></div>
						</label>
					</div>
				</div>
				<div class="fui-icon-group noborder col-7">
					<div class="fui-icon-col" ng-repeat="(k,value) in pagedata.kongday" style="margin-top:0">
						<label class="jyui_cell_col">
							
						</label>
					</div>
					<div class="fui-icon-col" ng-repeat="(k,value) in pagedata.calendar" style="margin-top:0" ng-click="duoxuans(value.day,pagedata.peiset,'days')">
						<label ng-class="{'jyui_cell_col':1,'disabled':value.islast==1}">
							<div ng-class="{'red':pagedata.peiset.days.indexOf(';'+value.day+';')>=0}">
								<span>{{value.i}}</span>
							</div>
						</label>
						<i ng-show="pagedata.peiset.days.indexOf(';'+value.day+';')>=0" class="icon icon-selected signed"></i>
					</div>
				</div>
				<div ng-click="pagedata.upall();" class="fui-cell-title c" style="color:#18bc9c;padding-top:0">
					<i class="icon icon-yuding" style="font-size:0.8rem"/>全选/取消
				</div>
		</div>
		<div class="fui-cellone" style="text-align:left">
				<div class="fui-cellone-info bold">预约配送时间段选择！</div>
				<div class="fui-cellone-remark noremark">
				<span class="btn btn-sm btn-success" style="background:#18bc9c;line-height:2" ng-click="pagedata.peiset.times='';">清空</span>
				</div>
		</div>
		<div class="radius" style="background:#fff">
			<div class="fui-cellone">
					<div class="fui-cellone-label" style="color:#18bc9c">早</div>
					<div class="fui-cellone-info"></div>
					<div class="fui-cellone-remark noremark" style="color:#18bc9c">预约早上时间</div>
				</div>
				<div class="fui-icon-group noborder col-3" style="padding:0 0.15rem">
					<div class="fui-icon-col" ng-repeat="item in pagedata.work_hours0" style="margin-top:0">
						<label class="jyui_cell_col" ng-click="duoxuans(item.timev,pagedata.peiset,'times')">
							<div ng-class="{'btn btn-gray':1,'red':pagedata.peiset.times.indexOf(';'+item.timev+';')>=0}" style="background:#f2f2f2;margin: 0.1rem;line-height:2">{{item.timev}}</div>
						</label>
						<i ng-show="pagedata.peiset.times.indexOf(';'+item.timev+';')>=0" class="icon icon-selected signed" style="top:0.3rem"></i>
					</div>
					<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.work_hours0 || pagedata.work_hours0.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的时间!
					</div>
				</div>
				<div class="fui-cellone">
					<div class="fui-cellone-label" style="color:#18bc9c">中</div>
					<div class="fui-cellone-info"></div>
					<div class="fui-cellone-remark noremark" style="color:#18bc9c">预约中午时间</div>
				</div>
				<div class="fui-icon-group noborder col-3" style="padding:0 0.15rem">
					<div class="fui-icon-col" ng-repeat="item in pagedata.work_hours1" style="margin-top:0">
						<label class="jyui_cell_col" ng-click="duoxuans(item.timev,pagedata.peiset,'times')">
							<div ng-class="{'btn btn-gray':1,'red':pagedata.peiset.times.indexOf(';'+item.timev+';')>=0}" style="background:#f2f2f2;margin: 0.1rem;line-height:2">{{item.timev}}</div>
						</label>
						<i ng-show="pagedata.peiset.times.indexOf(';'+item.timev+';')>=0" class="icon icon-selected signed" style="top:0.3rem"></i>
					</div>
					<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.work_hours1 || pagedata.work_hours1.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的时间!
					</div>
				</div>
				<div class="fui-cellone">
					<div class="fui-cellone-label" style="color:#18bc9c">晚</div>
					<div class="fui-cellone-info"></div>
					<div class="fui-cellone-remark noremark" style="color:#18bc9c">预约晚上时间</div>
				</div>
				<div class="fui-icon-group noborder col-3" style="padding:0 0.3rem">
					<div class="fui-icon-col" ng-repeat="item in pagedata.work_hours2" style="margin-top:0">
						<label class="jyui_cell_col" ng-click="duoxuans(item.timev,pagedata.peiset,'times')">
							<div ng-class="{'btn btn-gray':1,'red':pagedata.peiset.times.indexOf(';'+item.timev+';')>=0}" style="background:#f2f2f2;margin: 0.1rem;line-height:2">{{item.timev}}</div>
						</label>
					</div>
					<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.work_hours2 || pagedata.work_hours2.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的时间!
					</div>
				</div>
		</div>
        <div class="fui-cell-group">
                <div class="fui-cell small ">
                    <div class="fui-cell-info">
                        <label class="checkbox-inline">
                            <input type="checkbox" class="fui fui-checkbox fui-checkbox-danger" ng-checked="pagedata.peiset.agree==1" ng-model="pagedata.peiset.agree" /> 我已经阅读并了解了<a id="btn-apply" ng-click="pagedata.show_content=true" style="color:#337ab7;">【{{pagedata.yuyuexieyi.title}}】</a>。
                        </label>

                    </div>
                </div>
         </div>
         <div ng-show="pagedata.show_content" class="modal-bg pop-apply-hidden" >
                <div class="modal-content" style="top:10%;width:90%;left:5%">
                    <div class="closebtn" ng-click="pagedata.show_content=false" style="opacity:1;"><i class="icon icon-cuowu"></i></div>
                    <div class="news-body">
						<div class="title">{{pagedata.yuyuexieyi.title}} / <small>Read &nbsp;Ggree</small></div>
                        <div class="text" ng-bind-html="trust(pagedata.yuyuexieyi.content)"></div>
                    </div>
					<div class="modal-footer">
                            <div ng-click="pagedata.peiset.agree=1;pagedata.show_content=false" class="mod-check" style="width: 100%; margin: 0;">我已阅读</div>
                    </div>
                </div>
         </div>
        <div class='btn btn-danger block btn-submit' style="margin-top:1rem" ng-click="post(pagedata.peiset,'jy_peiorder/setpei/post/')">提交设置</div>
		 </div>
		</div>
</div>
<div class='fui-page fui-page-current' ng-if="pagedata.op=='goods'">
    <div class='fui-content'>
		<div style="padding:0.5rem">
       <div class="tips tips-yellow" style="margin:0">
               <i class="fa fa-bullhorn"></i> 设置本订单的预约定期配送商品数量和类型，如果不会设置，可以让配送员或者店员帮忙设置！
         </div>
		<div class="fui-cellone" style="text-align:left">
				<div class="fui-cellone-info bold">预约配送商品类型/数量</div>
				<div class="fui-cellone-remark noremark">
				</div>
		</div>
		<div class="fui-cell-group" style="padding:0 0.15rem">
				<div ng-repeat="g in pagedata.goods" class="fui-cell small">
                    <div class="fui-cell-info">
                        <div class="text">{{g.goods_title}}</div>
						<div class="subtitle">规格：{{g.optiontitle || '无'}}</div>
                    </div>
					<div class="fui-cell-remark noremark">
                        <div ng-if="!g.leixings || g.leixings.length<=0" class="fui-number small" style="right:0">
								<div ng-if="pagedata.peiset.goods[g.goodsid].num>0" class="minus" ng-click="pagedata.minus(g)"><i class="icon icon-subtract" style="font-size:0.7rem"></i></div>
								<input ng-if="pagedata.peiset.goods[g.goodsid].num>0" class="num shownum" type="text" ng-model="pagedata.peiset.goods[g.goodsid].num" style="width:1rem"/>
								<div class="plus" ng-click="pagedata.plus(g)"><i class="icon icon-tianjia" style="font-size:0.7rem"></i></div>
						</div>
						<div ng-repeat="(k,lv) in g.leixings" class="fui-cellone" style="padding:0">
							<div class="fui-cellone-info">{{lv.title}}</div>
							<div class="fui-cellone-remark noremark" style="margin-left:0.3rem">
							<div class="fui-number small" style="right:0">
								<div class="minus" ng-click="pagedata.minus2(g,k)"><i class="icon icon-subtract" style="font-size:0.7rem"></i></div>
								<input class="num shownum" type="text" ng-model="pagedata.peiset.goods[g.goodsid+'_'+k].num" style="width:1rem"/>
								<div class="plus" ng-click="pagedata.plus2(g,k)"><i class="icon icon-tianjia" style="font-size:0.7rem"></i></div>
							</div>
							</div>
						</div>
                    </div>
                </div>
				<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.goods || pagedata.goods.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的商品!
				</div>
		</div>
        <div class="fui-cell-group">
                <div class="fui-cell small ">
                    <div class="fui-cell-info">
                        <label class="checkbox-inline">
                            <input type="checkbox" class="fui fui-checkbox fui-checkbox-danger" ng-checked="pagedata.peiset.agree==1" ng-model="pagedata.peiset.agree" /> 我已经阅读并了解了<a id="btn-apply" ng-click="pagedata.show_content=true" style="color:#337ab7;">【{{pagedata.yuyuexieyi.title}}】</a>。
                        </label>

                    </div>
                </div>
         </div>
         <div ng-show="pagedata.show_content" class="modal-bg pop-apply-hidden" >
                <div class="modal-content" style="top:10%;width:90%;left:5%">
                    <div class="closebtn" ng-click="pagedata.show_content=false" style="opacity:1;"><i class="icon icon-cuowu"></i></div>
                    <div class="news-body">
						<div class="title">{{pagedata.yuyuexieyi.title}} / <small>Read &nbsp;Ggree</small></div>
                        <div class="text" ng-bind-html="trust(pagedata.yuyuexieyi.content)"></div>
                    </div>
					<div class="modal-footer">
                            <div ng-click="pagedata.peiset.agree=1;pagedata.show_content=false" class="mod-check" style="width: 100%; margin: 0;">我已阅读</div>
                    </div>
                </div>
         </div>
        <div class='btn btn-danger block btn-submit' style="margin-top:1rem" ng-click="post(pagedata.peiset,'jy_peiorder/setpei/postgoods/')">提交设置</div>
		 </div>
		</div>
</div>
<script language='javascript'>
scope.pagedata.gotoshowtime=function(){
	scope.get('jy_peiorder/setpei/get_work_time/',function(res){
		scope.pagedata.work_hours0=res.hours0;
		scope.pagedata.work_hours1=res.hours1;
		scope.pagedata.work_hours2=res.hours2;
		scope.$evalAsync();
	});
}
scope.pagedata.gotoshowtime();
scope.pagedata.getDates=function(){
	scope.get('jy_peiorder/setpei/time_days/year='+scope.pagedata.currentyear+'&month='+scope.pagedata.currentmonth,function(res){
		console.log(scope.pagedata.currentyear);
		scope.pagedata.kongday=res.kongday;
		scope.pagedata.calendar=res.calendar;
		scope.$evalAsync()
		return true;
	});
}
scope.pagedata.getDates();
scope.pagedata.upmonth=function(isadd){
	var currentmonth=parseInt(scope.pagedata.currentmonth);
	if(isadd==1){
		if(currentmonth==12){
			currentmonth=1
			scope.pagedata.currentyear++
		}else{
			currentmonth++
		}
	}
	if(isadd!=1){
		if(currentmonth==1){
			currentmonth=12
			scope.pagedata.currentyear--
		}else{
			currentmonth--
		}
	}
	if(currentmonth<10){
		scope.pagedata.currentmonth='0'+currentmonth
	}
	scope.pagedata.getDates();
	return true;
}
scope.pagedata.upall=function(){
	var calendar = Object.values(scope.pagedata.calendar)
	for(var i=0;i<calendar.length;i++){
		var value=calendar[i]
		scope.duoxuans(value,scope.pagedata.peiset,'days')
	}
	scope.$evalAsync();
}
//减少
scope.pagedata.minus=function(g){
	scope.pagedata.peiset.goods[g.goodsid]=scope.pagedata.peiset.goods[g.goodsid]?scope.pagedata.peiset.goods[g.goodsid]:{'num':0,'title':g.goods_title,'goodsid':g.goodsid}
	if(scope.pagedata.peiset.goods[g.goodsid].num<=0){
		return false;
	}
	scope.pagedata.peiset.goods[g.goodsid].num--
}
//增加
scope.pagedata.plus=function(g){
	scope.pagedata.peiset.goods[g.goodsid]=scope.pagedata.peiset.goods[g.goodsid]?scope.pagedata.peiset.goods[g.goodsid]:{'num':0,'title':g.goods_title,'goodsid':g.goodsid}
	if(scope.pagedata.peiset.goods[g.goodsid].num>=g.lastnum){
		scope.message('不能再添加了，已超过剩余商品数量！','error');
		return false;
	}
	scope.pagedata.peiset.goods[g.goodsid].num++
}
//减少
scope.pagedata.minus2=function(g,k){
	scope.pagedata.peiset.goods[g.goodsid+'_'+k]=scope.pagedata.peiset.goods[g.goodsid+'_'+k]?scope.pagedata.peiset.goods[g.goodsid+'_'+k]:{'num':0,'title':g.goods_title,'goodsid':g.goodsid}
	scope.pagedata.peiset.goods[g.goodsid+'_'+k].title=g.goods_title
	scope.pagedata.peiset.goods[g.goodsid+'_'+k].ktitle=g.leixings[k].title
	if(scope.pagedata.peiset.goods[g.goodsid+'_'+k].num<=0){
		return false;
	}
	scope.pagedata.peiset.goods[g.goodsid+'_'+k].num--
}
//增加
scope.pagedata.plus2=function(g,k){
	scope.pagedata.peiset.goods[g.goodsid+'_'+k]=scope.pagedata.peiset.goods[g.goodsid+'_'+k]?scope.pagedata.peiset.goods[g.goodsid+'_'+k]:{'num':0,'title':g.goods_title,'goodsid':g.goodsid}
	scope.pagedata.peiset.goods[g.goodsid+'_'+k].goodsid=g.goodsid
	scope.pagedata.peiset.goods[g.goodsid+'_'+k].title=g.goods_title
	scope.pagedata.peiset.goods[g.goodsid+'_'+k].ktitle=g.leixings[k].title
	var isnum=0;
	for(var i=0;i<g.leixings.length;i++){
		scope.pagedata.peiset.goods[g.goodsid+'_'+i]=scope.pagedata.peiset.goods[g.goodsid+'_'+i]?scope.pagedata.peiset.goods[g.goodsid+'_'+i]:0;
		isnum=isnum+scope.pagedata.peiset.goods[g.goodsid+'_'+i].num
	}
	if(isnum>=g.lastnum){
		scope.message('不能再添加了，已超过剩余商品数量'+g.lastnum+'！','error');
		return false;
	}
	scope.pagedata.peiset.goods[g.goodsid+'_'+k].num++
}
</script>